package cn.cs.service;

import cn.cs.mapper.RepOrderMapper;
import cn.cs.pojo.*;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
public class RestRepOrderService {
    @Resource
    private RepOrderMapper repOrderMapper;
    @RequestMapping(value = "/insertRepOrder", method = RequestMethod.POST)
    @Transactional
    public int insertRepOrder(@RequestBody RepOrder order) {
        return repOrderMapper.insertRepOrder(order);
    }
    @RequestMapping(value = "/getOrderByAppOrderId", method = RequestMethod.POST)
    @Transactional
    RepOrder getRepOrderByAppOrderId(@RequestParam("id")String id){
        return repOrderMapper.getRepOrderByAppOrderId(id);
    }

    @RequestMapping(value = "/getAllRepOrders", method = RequestMethod.POST)
    @Transactional
    List<RepOrder> getAllRepOrders(@RequestBody Map<String, Object> parm){
        return repOrderMapper.getAllRepOrders(parm);
    }
    @RequestMapping(value = "/getRepOrderById", method = RequestMethod.POST)
    @Transactional
    RepOrder getRepOrderById(@RequestParam("id")String id){
        return repOrderMapper.getRepOrderById(id);
    }
    @RequestMapping(value = "/getRepProsByOrderId", method = RequestMethod.POST)
    @Transactional
    List<RepProduct> getRepProsByOrderId(@RequestBody Map<String, Object> param){
        return repOrderMapper.getRepProsByOrderId(param);
    }
    @RequestMapping(value = "/getAllrepEva", method = RequestMethod.POST)
    @Transactional
    public List<Map<String, Object>> getAllrepEva(@RequestParam("id")String id) {
        return repOrderMapper.getAllrepEva(id);
    }

    @RequestMapping(value = "/insertQrHistory", method = RequestMethod.POST)
    @Transactional
    public void insertQrHistory(@RequestBody QrHistory qrHistory) {
        repOrderMapper.insertQrHistory(qrHistory);
    }
    @RequestMapping(value = "/insertRepProduct", method = RequestMethod.POST)
    @Transactional
    public void insertRepProduct(@RequestBody RepProduct repProduct) {
        repOrderMapper.insertRepProduct(repProduct);
    }
    @RequestMapping(value = "/getRepairPercentage", method = RequestMethod.POST)
    @Transactional
    public Map<String, Object> getRepairPercentage() {
        return repOrderMapper.getRepairPercentage();
    }
    @RequestMapping(value = "/updateRepOrder", method = RequestMethod.POST)
    @Transactional
    public int updateRepOrder(@RequestBody RepOrder repOrder) {
        return repOrderMapper.updateRepOrder(repOrder);
    }
    @RequestMapping(value = "/insertOrderBillImg", method = RequestMethod.POST)
    @Transactional
    public void insertOrderBillImg(@RequestBody Map<String, Object> map) {
        repOrderMapper.insertOrderBillImg(map);
    }

    @RequestMapping(value = "/insertTestReport", method = RequestMethod.POST)
    @Transactional
    public int insertTestReport(@RequestBody RepairTestReport testReport) {
        return repOrderMapper.insertTestReport(testReport);
    }
    @RequestMapping(value = "/getRepProTypes", method = RequestMethod.POST)
    @Transactional
    public List<Map<String, Object>> getRepProTypes() {
        return repOrderMapper.getRepProTypes();
    }
    @RequestMapping(value = "/getRepProTypesById", method = RequestMethod.POST)
    @Transactional
    public List<Map<String, Object>> getRepProTypesById(@RequestParam("typeId")String typeId) {
        return repOrderMapper.getRepProTypesById(typeId);
    }
    @RequestMapping(value = "/getQrHistoryByQrCode", method = RequestMethod.POST)
    @Transactional
    public List<Map<String, Object>> getQrHistoryByQrCode(@RequestParam("qrCode")String qrCode) {
        return repOrderMapper.getQrHistoryByQrCode(qrCode);
    }
    @RequestMapping(value = "/getTestReportByOrderId", method = RequestMethod.POST)
    @Transactional
    public RepairTestReport getTestReportByOrderId(@RequestParam("orderId")String orderId) {
        return repOrderMapper.getTestReportByOrderId(orderId);
    }
    @RequestMapping(value = "/getTestReportImgsById", method = RequestMethod.POST)
    @Transactional
    public List<Map<String, Object>> getTestReportImgsById(@RequestParam("id")String id) {
        return repOrderMapper.getTestReportImgsById(id);
    }

    @RequestMapping(value = "/insertRepImg", method = RequestMethod.POST)
    @Transactional
    public void insertRepImg(@RequestBody Map<String, Object> map) {
        repOrderMapper.insertRepImg(map);
    }

    @RequestMapping(value = "/getBillOrderImg", method = RequestMethod.POST)
    @Transactional
    public List<Map<String, Object>> getBillOrderImg(@RequestParam("orderId")String orderId) {
        return repOrderMapper.getBillOrderImg(orderId);
    }

    @RequestMapping(value = "/getHbRepOrderList", method = RequestMethod.POST)
    @Transactional
    public List<Map<String, Object>> getHbRepOrderList(@RequestBody Map<String, Object> param) {
        return repOrderMapper.getHbRepOrderList(param);
    }

    @RequestMapping(value = "/getRepOrderEvlById", method = RequestMethod.POST)
    @Transactional
    public Map<String, Object> getRepOrderEvlById(@RequestParam("orderId")String orderId) {
        return repOrderMapper.getRepOrderEvlById(orderId);
    }

    @RequestMapping(value = "/updateRepairPercentage", method = RequestMethod.POST)
    public Integer updateRepairPercentage(@RequestBody Map<String,Object> map) throws  Exception{
        return repOrderMapper.updateRepairPercentage(map);
    }

    @RequestMapping(value = "/getOrderDetailsByOrderId", method = RequestMethod.POST)
    public List<Map<String, Object>> getOrderDetailsByOrderId(@RequestParam("orderId") String orderId, @RequestParam("type") String type){
        return repOrderMapper.getOrderDetailsByOrderId(orderId, type);
    }

    @RequestMapping(value = "/getOrderInvoiceByUserId", method = RequestMethod.POST)
    public List<Map<String, Object>>getOrderInvoiceByUserId(@RequestParam("userId") String userId, @RequestParam("phone") String phone)throws Exception{
        return repOrderMapper.getOrderInvoiceByUserId(userId, phone);
    }

    @RequestMapping(value = "/updateOrderByIds", method = RequestMethod.POST)
    public int updateOrderByIds(@RequestBody String[] params)throws Exception{
        return repOrderMapper.updateOrderByIds(params);
    }

    @RequestMapping(value = "/getOrderInvoiceByUserPId", method = RequestMethod.POST)
    public List<Map<String, Object>>getOrderInvoiceByUserPId(@RequestParam("userId") String userId)throws Exception{
        return repOrderMapper.getOrderInvoiceByUserPId(userId);
    }
    @RequestMapping(value = "/updateRepOrderBillState", method = RequestMethod.POST)
    int  updateRepOrderBillState(@RequestBody RepOrder repOrder){
        return repOrderMapper.updateRepOrderBillState(repOrder);
    }

    @RequestMapping(value = "/getServiceType", method = RequestMethod.POST)
    List<Map<String,Object>> getServiceType(){
        return  repOrderMapper.getServiceType();
    }
    @RequestMapping(value = "/getFaultType", method = RequestMethod.POST)
    List<Map<String,Object>> getFaultType(@RequestParam("id") String id){
        return  repOrderMapper.getFaultType(id);
    }

    @RequestMapping(value = "/getMyEarningsByDay", method = RequestMethod.POST)
    @Transactional
    public List<Map<String, Object>> getMyEarningsByDay(@RequestBody Map<String, Object> map) {
        return repOrderMapper.getMyEarningsByDay(map);
    }

    @RequestMapping(value = "/getCountMyEarnings", method = RequestMethod.POST)
    @Transactional
    public List<Map<String, Object>> getCountMyEarnings(@RequestBody Map<String, Object> map) {
        return repOrderMapper.getCountMyEarnings(map);
    }

    @RequestMapping(value = "/getSetMoney", method = RequestMethod.POST)
    @Transactional
    public String getSetMoney(Map<String, Object> param) {
        return repOrderMapper.getSetMoney(param);
    }
}
